home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DDJMAG / DDJ9203.ZIP / OOPASM.ZIP / MASTER.ASM < prev    next >
Assembly Source File  |  1990-07-10  |  3KB  |  133 lines

  1.     .MODEL    SMALL
  2.  
  3.     INCLUDE    equates.inc
  4.     INCLUDE    instance.inc
  5.     INCLUDE    messages.inc
  6.     INCLUDE    objects.inc
  7.  
  8. IF1
  9.     INCLUDE    macros.mac
  10.     INCLUDE    objects.mac
  11. ENDIF
  12.  
  13.     EXTRN    sendMsg:NEAR
  14.  
  15.     EXTRN    Self:WORD
  16.  
  17.     .CODE
  18.  
  19. COMMENT    %
  20. ==============================================================================
  21. For all slaves pointed to by SlaveTbl, sets their MasterObj pointer to 
  22. point to Self.
  23.  
  24. =============================================================================%
  25. enslave    PROC    NEAR
  26.     getInst        bx,SlaveTbl,Self    ;Get slave tbl ptr
  27.     iterate        bx,2,setMaster        ;Call setMaster for each obj
  28.     ret
  29. enslave    ENDP
  30.  
  31.  
  32.  
  33. COMMENT    %
  34. ==============================================================================
  35. Sets a slave's MasterObj pointer to point to Self.
  36.  
  37. Passed:    bx - Ptr to slave tbl
  38.  
  39. =============================================================================%
  40. setMaster    PROC    NEAR
  41.     push        Self
  42.     mov        ax,Wptr[Self]        ;Save Self
  43.     push        Wptr[bx]        ;Reset Self to slave obj
  44.     pop        Self
  45.     setInst        MasterObj,ax,Self    ;Set slave's master ptr
  46.     pop        Self
  47.     ret
  48. setMaster    ENDP
  49.  
  50.  
  51.  
  52. COMMENT    %
  53. ==============================================================================
  54. Passes the Refresh message to slave objects.
  55.  
  56. =============================================================================%
  57. slaveRefresh    PROC    NEAR
  58.     getInst        bx,SlaveTbl,Self    ;Get slave tbl ptr
  59.     sendSlaves    bx,Refresh        ;Send Refresh to all slaves
  60.     ret
  61. slaveRefresh    ENDP
  62.  
  63.  
  64.  
  65. COMMENT    %
  66. ==============================================================================
  67. Passes the Read message to slave objects.
  68.  
  69. =============================================================================%
  70. slaveRead    PROC    NEAR
  71.     getInst        bx,SlaveTbl,Self    ;Get slave tbl ptr
  72.     sendSlaves    bx,Read            ;Send Read to all slaves
  73.     ret
  74. slaveRead    ENDP
  75.  
  76.  
  77.  
  78. IF Dbug
  79.     PUBLIC    slaveSelect
  80. ENDIF
  81. COMMENT    %
  82. ==============================================================================
  83. Passes the Select message to slave objects.
  84.  
  85. =============================================================================%
  86. slaveSelect    PROC    NEAR
  87.     getInst        bx,SlaveTbl,Self    ;Get slave tbl ptr
  88.     sendSlaves    bx,Select        ;Send Select to all slaves
  89.     ret
  90. slaveSelect    ENDP
  91.  
  92.  
  93.  
  94.     PUBLIC    makeActive
  95. COMMENT    %
  96. ==============================================================================
  97. Makes a slave object active by stuffing a pointer to it in the master's
  98. ActiveSlave instance variable.
  99.  
  100. =============================================================================%
  101. makeActive    PROC    NEAR
  102.     mov        ax,Wptr[Self]        ;Get current object ptr
  103.     setInst$    ActiveSlave,ax,MasterObj
  104.     ret
  105. makeActive    ENDP
  106.  
  107.  
  108.  
  109.     .DATA
  110.  
  111. defMsg    Master,\
  112.     Refresh,\
  113.     <enslave,,slaveRefresh>
  114.  
  115. defMsg    Master,\
  116.     Read,\
  117.     <,,slaveRead>
  118.  
  119. defMsg    Master,\
  120.     Select,\
  121.     <,,slaveSelect>
  122.  
  123. defObj    Master,\
  124.     <>,\
  125.     <>,\
  126.     <Refresh,Read,Select>
  127.  
  128.  
  129.  
  130.     END
  131.  
  132.  
  133.